﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mvc4MusicStore.Viewmodel;
using Mvc4MusicStore.Models;

namespace Mvc4MusicStore.Controllers
{
    public class StoreController : Controller
    {
        private MusicStoreEntities storeDB = new MusicStoreEntities();
        public ActionResult Browse(string genre)
        {
            // Retrieve Genre and its Associated Albums from database
            var genreModel = new Genre
            {
                Name = genre,
                Albums = this.storeDB.Albums.ToList()
            };

            return this.View(genreModel);
        }

        public ActionResult Index()
        {
            var genres = this.storeDB.Genres;

            return this.View(genres);
        }
        [ChildActionOnly]
        public ActionResult GenreMenu()
        {
            var genres = this.storeDB.Genres.Take(9).ToList();

            return this.PartialView(genres);
        }

    }
}
